import Vue from 'vue'
import xss from 'xss'

const options = {
  whiteList: {
    a: ['href', 'title', 'target', 'style'],
    span: ['style'],
    img: ['src', 'alt', 'style'],
    br: [],
    p: ['style'],
    div: ['style'],
    h1: ['style'],
    h2: ['style'],
    h3: ['style'],
    h4: ['style'],
    h5: ['style'],
    h6: ['style']
  }
};

const filter = {
  install(Vue) {
    Vue.prototype.xssfilter = function(val) {
      return xss(val, options)
    }

    Vue.filter('xss', Vue.prototype.xssfilter);
  }
}

Vue.use(filter)